package com.gencode.generate.web.controller;
import com.gencode.generate.persistence.model.TActivity;
import com.gencode.generate.service.TActivityService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by fenglibin on 2019/03/12.
 */
@Controller
@RequestMapping("/tActivity/")
public class TActivityController {

    @Autowired
    TActivityService tActivityService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TActivity>> selectAll(){
        return Result.success(tActivityService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TActivity> selectByPrimaryKey(Long id){
        return Result.success(tActivityService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TActivity>> selectByCondition(TActivity record){
        return Result.success(tActivityService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TActivity record){
        return Result.success(tActivityService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TActivity record){
        return Result.success(tActivityService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TActivity record){
        return Result.success(tActivityService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TActivity>>> selectByPage(Page<TActivity> page){
        List<TActivity> list = null;
        page = page.sequentialDisplayCalculate(tActivityService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tActivityService.selectByPage(page);
        }
        Page<List<TActivity>> result = new Page<List<TActivity>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TActivity record){
        return Result.success(tActivityService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Long id){
        return Result.success(tActivityService.deleteByPrimaryKey(id));
    }

}
